<template>
  <a-card style="margin-top:-2px" :bordered="false">
    <div class="">
      <a-form >
        <!--查询条件 start-->
        <a-row class="form-row" >
          <a-col :span="10" :offset="1">
            <a-form-item
              label="主题名称"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol">
              <a-input style="width:210px" v-model="queryParam.theme"/>
            </a-form-item>
          </a-col>
        </a-row>
        <!--查询条件 end-->
        <!--操作按钮 start -->
        <a-row :gutter="24" algin="center" style="margin-top:10px" >
          <a-col :md="12">
            <span style="float:right" class="table-page-search-submitButtons">
              <a-button type="primary" @click="search">查询</a-button>
              <a-button style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button>
            </span>
          </a-col>
        </a-row>
        <!--操作按钮 end -->
      </a-form>
    </div>
    <my-table
      ref="mystable"
      size="default"
      :columns="columns"
      :data="myLoadData"
      style="margin-top:10px"
    >
      <span slot="action" slot-scope="text, record">
        <a @click="modelMethod(record)">下载</a>
      </span>
    </my-table>
  </a-card>
</template>
<script >
import { STable } from '@/components'
import { query } from '@/api/admin'
import { fileDownload } from '@/utils/util'
export default {
  components: {
    myTable: STable
  },
  data () {
    return {
      form: this.$form.createForm(this),
      // 查询参数
      queryParam: {}, // 查询条件
      // 加载数据方法 必须为 Promise 对象
      myLoadData: parameter => {
        return query('/generator/code/generatorfile/page', 'GET', parameter, {})
          .then(res => {
            return res.result
          })
      },
      // 表头
      columns: [
        { title: '主题名称', dataIndex: 'theme' },
        { title: '所属项目',
          dataIndex: 'pname'
        },
        { title: '生成人', dataIndex: 'cname' },
        { title: '生成时间', dataIndex: 'ctime' },
        { title: '备注', dataIndex: 'remark' },
        { title: '操作', width: '200px', dataIndex: 'action', scopedSlots: { customRender: 'action' }
        }
      ],
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      modelVisible: false, // 弹出框显示
      operate: 'QUERY', // 当前操作
      selectInfo: {}, // 选中的数据
      confirmLoading: false // Loading
    }
  },
  created () {
  },
  methods: {
    /**
     * 搜索
     */
    search () {
      this.$refs.mystable.loadData({}, this.queryParam)
    },
    // 操作按钮
    modelMethod (selectInfo) {
      this.selectInfo = Object.assign({}, selectInfo) // 记录当前操作的数据
      // const _this = this
      // const a = document.createElement('a')
      // a.href = 'http://127.0.0.1:8089/zzFileManage/downloadFileOwn?fileId=TqTn6LdF'
      // a.click()
      console.log(selectInfo.path)
      fileDownload('', '')
    }
  }
}
</script>
<style scoped>

</style>
